package com.probox.activity.api.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.probox.common.core.enums.ActivityJoinStatusEnum;
import com.probox.common.core.enums.ActivityTypeEnum;
import com.probox.common.core.enums.BargainEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@ApiModel("砍价商品vo")
public class ActivityBargainVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "商品uid")
    private Long productUid;

    @ApiModelProperty(value = "商品名称")
    private String productName;

    @ApiModelProperty(value = "商品详情图")
    private String proImg;

    @ApiModelProperty(value = "skuid")
    private Long skuUid;

    @ApiModelProperty(value = "发起者ID")
    private Long joinUid;

    @ApiModelProperty(value = "活动ID")
    private Long activityUid;

    @ApiModelProperty(value = "活动名称")
    private String activityName;

    @ApiModelProperty(value = "活动类型")
    private String activityType;

    @ApiModelProperty(value = "活动商品ID")
    private Long activityProUid;

    //活动金额
    @ApiModelProperty(value = "活动金额")
    private Long activityPrice;

    //已砍价金额
    @ApiModelProperty(value = "已砍价金额")
    private Long bargainAmount;

    @ApiModelProperty(value = "参与时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    //砍价过期时间
    @ApiModelProperty(value = "砍价过期时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date expireDate;

    /**
     * 0:进行中 1:已参加  2:已成功，-1已失败
     */
    @ApiModelProperty(value = "参与状态(0:进行中/1:已付款/2：成交/-1:参与失败)")
    private String dataStatus;

    /**
     * 	砍价状态，0未帮砍  1已帮砍  2我发起的砍价
     */
    @ApiModelProperty(value = "砍价状态(0未帮砍  1已帮砍  2我发起的砍价)")
    private String bargainStatus;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    @ApiModelProperty(value = "活动倒计时")
    private long endTimes;


    @ApiModelProperty(value = "预留支付/砍价时长，单位分钟")
    private Long payMinute;

    //规则
    @ApiModelProperty(value = "规则")
    private String rule;

    private Long customerUid;
    private String customerName;
    private Long platformUid;


    public double getProcess() {
        return new Double(bargainAmount*1.0/activityPrice*1.0*10000).longValue()/100.00;
    }

    public String getBargainStatusName(){
        return BargainEnum.getNameByKey(bargainStatus);
    }

    public String getDataStatusName(){
        if(ActivityTypeEnum.bargain.getKey().equals(activityType)
                && ActivityJoinStatusEnum.pay.getKey().equals(dataStatus)){
            return "砍价成功";
        }
        return ActivityJoinStatusEnum.getNameByKey(dataStatus);
    }

}
